<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>21-表单的基本操作</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <style></style>
  </head>
  <body>
    <div id="app">
      <form>
        <label>姓名：</label><input type="text" v-model="uname" /><br />
        <label>性别：</label>
        男：<input type="radio" value="1" v-model="sex" /> 女：<input
          type="radio"
          value="2"
          v-model="sex"
        />
        <br />
        <label
          >爱好： <span>篮球：</span
          ><input type="checkbox" value="1" v-model="hobby" />
          <span>足球：</span
          ><input type="checkbox" value="2" v-model="hobby" />
          <span>羽毛球：</span
          ><input type="checkbox" value="3" v-model="hobby" />
        </label>
        <br />
        <label>职业：</label><br />
        <select multiple v-model="zhiye" style="width: 150px">
          <option value="律师">律师</option>
          <option value="">医生</option>
          <option value="教师">教师</option>
        </select>
        <span>留言板：</span>
        <textarea cols="30" rows="10" v-model="textareaVal"></textarea>
      </form>
      <input type="submit" value="提交" @click.prevent="sendForm($event)" />
    </div>
    <script>
      var vm = new Vue({
        el: '#app',
        data: {
          uname: 'zs',
          sex: 2,
          hobby: [1, 3],
          zhiye: ['律师', '医生', '教师'],
          textareaVal: '输点啥呢？',
          sayHi: 'hello',
        },
        methods: {
          sendForm: function (e) {
            console.log(e.target.value);
            console.log(this.sayHi);
          },
        },
      });
    </script>
  </body>
</html>
